package com.yang.mall.entity;

import lombok.Data;

import java.io.Serializable;

/**
 * @author Vean
 */
@Data
public class OLResponse<T> implements Serializable {

    private static final long serialVersionUID = -8713837128340960775L;

    private String code;

    private String message;

    private T data;

    public OLResponse<T> success(T data) {
        this.message = "成功";
        this.code = "0";
        this.data = data;
        return this;
    }

    public OLResponse<T> success() {
        this.message = "成功";
        this.code = "0";
        return this;
    }

    public OLResponse<T> fail(String message) {
        this.message = message;
        this.code = "-1";
        return this;
    }

    public OLResponse(){}

    public OLResponse(String message){
        this.message = message;
    }

    public OLResponse(T data){
        this.data = data;
    }

    public OLResponse(String code, String message){
        this.code = code;
        this.message = message;
    }

    public OLResponse(String code, String message, T data){
        this.code = code;
        this.message = message;
        this.data = data;
    }
}
